package com.xiaoshuidi.cloud.module.rooms.controller.app.entrust;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.operatelog.core.annotations.OperateLog;
import com.xiaoshuidi.cloud.framework.security.core.LoginUser;
import com.xiaoshuidi.cloud.framework.security.core.util.SecurityFrameworkUtils;
import com.xiaoshuidi.cloud.module.rooms.controller.app.entrust.dto.PersonalEntrustCreateDTO;
import com.xiaoshuidi.cloud.module.rooms.controller.app.entrust.vo.SendEntrustCaptchaReqVO;
import com.xiaoshuidi.cloud.module.rooms.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.rooms.service.EntrustService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.PermitAll;
import javax.validation.Valid;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Tag(name = "租客端 - 个人委托")
@RestController
@RequestMapping(ApiConstants.NAME + "/entrust")
@RequiredArgsConstructor
public class EntrustController {

    private final EntrustService entrustService;

    @Operation(summary = "提交个人委托")
    @PostMapping("/personal-entrust")
    public CommonResult<Long> personalEntrust(@RequestBody @Valid PersonalEntrustCreateDTO personalEntrustCreateDTO){
        LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
        personalEntrustCreateDTO.setOperatorId(loginUser.getId());
        personalEntrustCreateDTO.setOperatorName(loginUser.getNickname());
        return entrustService.personalEntrust(personalEntrustCreateDTO);
    }

}
